Skip to content

Harden chart README workflow against fork PR checkout#21

Merged
perplexedmontagna merged 1 commit into
perplexityai:mainfrom
thom-pplx:fix/harden-chart-readme-workflow
May 18, 2026
Merged

Harden chart README workflow against fork PR checkout#21
perplexedmontagna merged 1 commit into
perplexityai:mainfrom
thom-pplx:fix/harden-chart-readme-workflow

Conversation

@thom-pplx
Copy link
Copy Markdown
Contributor

Summary

Hardens .github/workflows/generate-chart-readme.yaml against the fork PR pull_request_target checkout issue demonstrated in #20.

The workflow still updates chart README metadata for trusted same-repository PR branches, but it no longer runs as a privileged pull_request_target job against fork-controlled code.

Changes

  • Switch the trigger from pull_request_target to pull_request.
  • Skip the write-back job unless the PR branch is in this repository.
  • Checkout only github.repository, not the PR-controlled head.repo.full_name.
  • Checkout the immutable PR head SHA instead of a mutable head ref.
  • Set persist-credentials: false so checkout credentials are not available to later steps.
  • Provide GITHUB_TOKEN only to the final push step, after generation is complete.
  • Keep actions/checkout pinned, updated to the current v6 commit.

Why this is minimal

The workflow still uses the same path trigger, generator, commit message, and README update flow for same-repo PRs. Fork-origin PRs are the only behavior removed from the privileged write path, which is the vulnerable case.

Validation

  • Parsed the workflow YAML successfully.
  • Ran git diff --check.

@perplexedmontagna perplexedmontagna merged commit 67e70e4 into perplexityai:main May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants